package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Hudongleixing;
import com.ruoyi.system.domain.Huodongguize;
import com.ruoyi.system.domain.Yonghuleixing;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Pingtaiyouhui;
import com.ruoyi.system.service.IPingtaiyouhuiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台优惠活动，存储平台上的各种优惠活动信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/pingtaiyouhui")
public class PingtaiyouhuiController extends BaseController
{
    @Autowired
    private IPingtaiyouhuiService pingtaiyouhuiService;

    /**
     * 查询平台优惠活动，存储平台上的各种优惠活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pingtaiyouhui pingtaiyouhui)
    {
        startPage();
        List<Pingtaiyouhui> list = pingtaiyouhuiService.selectAll(pingtaiyouhui);
        // List<Pingtaiyouhui> list = pingtaiyouhuiService.selectPingtaiyouhuiList(pingtaiyouhui);
        return getDataTable(list);
    }

    @GetMapping("/yhlist")
    public TableDataInfo yhlist(Yonghuleixing yonghuleixing){
        List<Yonghuleixing> list = pingtaiyouhuiService.selectYonghuleixing(yonghuleixing);
        return getDataTable(list);
    }

    @GetMapping("/hdlist")
    public TableDataInfo hdlist(Huodongguize huodongguize){
        List<Huodongguize> list = pingtaiyouhuiService.selectHuodongguize(huodongguize);
        System.out.println(list);
        return getDataTable(list);
    }

    @GetMapping("/lxlist")
    public TableDataInfo lxlist(Hudongleixing hudongleixing){
        List<Hudongleixing> list = pingtaiyouhuiService.selectHudongleixing(hudongleixing);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 导出平台优惠活动，存储平台上的各种优惠活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:export')")
    @Log(title = "平台优惠活动，存储平台上的各种优惠活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Pingtaiyouhui pingtaiyouhui)
    {
        List<Pingtaiyouhui> list = pingtaiyouhuiService.selectPingtaiyouhuiList(pingtaiyouhui);
        ExcelUtil<Pingtaiyouhui> util = new ExcelUtil<Pingtaiyouhui>(Pingtaiyouhui.class);
        util.exportExcel(response, list, "平台优惠活动，存储平台上的各种优惠活动信息数据");
    }

    /**
     * 获取平台优惠活动，存储平台上的各种优惠活动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:query')")
    @GetMapping(value = "/{ptyhId}")
    public AjaxResult getInfo(@PathVariable("ptyhId") Long ptyhId)
    {
        return success(pingtaiyouhuiService.selectPingtaiyouhuiByPtyhId(ptyhId));
    }

    /**
     * 新增平台优惠活动，存储平台上的各种优惠活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:add')")
    @Log(title = "平台优惠活动，存储平台上的各种优惠活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pingtaiyouhui pingtaiyouhui)
    {
        return toAjax(pingtaiyouhuiService.insertPingtaiyouhui(pingtaiyouhui));
    }

    /**
     * 修改平台优惠活动，存储平台上的各种优惠活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:edit')")
    @Log(title = "平台优惠活动，存储平台上的各种优惠活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pingtaiyouhui pingtaiyouhui)
    {
        return toAjax(pingtaiyouhuiService.updatePingtaiyouhui(pingtaiyouhui));
    }

    /**
     * 删除平台优惠活动，存储平台上的各种优惠活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:pingtaiyouhui:remove')")
    @Log(title = "平台优惠活动，存储平台上的各种优惠活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ptyhIds}")
    public AjaxResult remove(@PathVariable Long[] ptyhIds)
    {
        return toAjax(pingtaiyouhuiService.deletePingtaiyouhuiByPtyhIds(ptyhIds));
    }
}
